import org.junit.Test;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.VideoWriter;

public class VideoConverter {

    @Test
    public void convert() {
        System.setProperty("java.awt.headless", "false");
        System.load(this.getClass().getClassLoader().getResource("opencv_java451.dll").getPath());
        //System.loadLibrary(Core.NATIVE_LIBRARY_NAME);

        for (int j = 0; j < 22; j++) {

            VideoCapture videoCapture = new VideoCapture("f:\\in1.mp4");

            VideoWriter videoWriter = new VideoWriter("f:\\out1\\" + j + ".mp4", (int) videoCapture.get(6), (double) videoCapture.get(5), new Size(videoCapture.get(3), videoCapture.get(4)));

            for (int i = 0; i < videoCapture.get(7); i++) {
                Mat mat = new Mat();
                Mat newMat = new Mat();
                videoCapture.read(mat);
                Imgproc.applyColorMap(mat, newMat, j);
                videoWriter.write(newMat);
            }
            videoWriter.release();
            videoCapture.release();
        }
    }

}
